<html>
<head>
  <script src="sorttable.js"></script>
  <script src="sourceview.js"></script>
  <link rel="stylesheet" type="text/css" href="style.css">
  <title>zcov: /home/vagrant/workspace/proj_libjpeg/cov/jutils.c</title>
</head>
<body>
<center><h1> zcov: <a href="index.html">/home/vagrant/workspace/proj_libjpeg/cov</a>/<a href="jutils.c.html">jutils.c</a> </h1></center>
<hr>


<center>
<table id="headertable" cellpadding=2>
  <tr>
    <td bgcolor=#ACACFF> <b>Files:</b> </td>
    <td bgcolor=#F0F0FF> 1 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Branches&nbsp;Taken:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>100.0%<b> </td>
    <td bgcolor=#F0F0FF align=right> 2&nbsp;/&nbsp;2 </td>
  </tr>
  <tr>
    <td bgcolor=#ACACFF> <b>Generated:</b> </td>
    <td bgcolor=#F0F0FF> 2016-04-07&nbsp;17:52 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Branches&nbsp;Executed:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>100.0%<b> </td>
    <td bgcolor=#F0F0FF align=right> 2&nbsp;/&nbsp;2 </td>
  </tr>
  <tr>
    <td colspan=2> </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Line&nbsp;Coverage:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>85.0%</b> </td>
    <td bgcolor=#F0F0FF align=right> 17&nbsp;/&nbsp;20 </td>
  </tr>
</table>
</center>
<p>
<hr>

<center>
<table id="fileheadertable" cellpadding=2>
  <tr>
    <td bgcolor=#ACACFF> <b>Programs:</b> </td>
    <td bgcolor=#F0F0FF> 1 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Runs</b> </td>
    <td bgcolor=#F0F0FF align=right> 5570 </td>
  </tr>
</table>
</center>
<p>
<hr>

<pre>
<span class="lineNum">       1 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">       2 </span>                :  * jutils.c
<span class="lineNum">       3 </span>                :  *
<span class="lineNum">       4 </span>                :  * Copyright (C) 1991-1996, Thomas G. Lane.
<span class="lineNum">       5 </span>                :  * This file is part of the Independent JPEG Group's software.
<span class="lineNum">       6 </span>                :  * For conditions of distribution and use, see the accompanying README file.
<span class="lineNum">       7 </span>                :  *
<span class="lineNum">       8 </span>                :  * This file contains tables and miscellaneous utility routines needed
<span class="lineNum">       9 </span>                :  * for both compression and decompression.
<span class="lineNum">      10 </span>                :  * Note we prefix all global names with &quot;j&quot; to minimize conflicts with
<span class="lineNum">      11 </span>                :  * a surrounding application.
<span class="lineNum">      12 </span>                :  */</FONT></I>
<span class="lineNum">      13 </span>                : 
<span class="lineNum">      14 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">JPEG_INTERNALS</FONT>
<span class="lineNum">      15 </span>                : #<B><FONT COLOR="#5F9EA0">include</FONT></B> <B><FONT COLOR="#BC8F8F">&quot;jinclude.h&quot;</FONT></B>
<span class="lineNum">      16 </span>                : #<B><FONT COLOR="#5F9EA0">include</FONT></B> <B><FONT COLOR="#BC8F8F">&quot;jpeglib.h&quot;</FONT></B>
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : 
<span class="lineNum">      19 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">      20 </span>                :  * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element
<span class="lineNum">      21 </span>                :  * of a DCT block read in natural order (left to right, top to bottom).
<span class="lineNum">      22 </span>                :  */</FONT></I>
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span>                : #<B><FONT COLOR="#5F9EA0">if</FONT></B> 0				<I><FONT COLOR="#B22222">/* This table is not actually needed in v6a */</FONT></I>
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : <B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> jpeg_zigzag_order[DCTSIZE2] = {
<span class="lineNum">      27 </span>                :    0,  1,  5,  6, 14, 15, 27, 28,
<span class="lineNum">      28 </span>                :    2,  4,  7, 13, 16, 26, 29, 42,
<span class="lineNum">      29 </span>                :    3,  8, 12, 17, 25, 30, 41, 43,
<span class="lineNum">      30 </span>                :    9, 11, 18, 24, 31, 40, 44, 53,
<span class="lineNum">      31 </span>                :   10, 19, 23, 32, 39, 45, 52, 54,
<span class="lineNum">      32 </span>                :   20, 22, 33, 38, 46, 51, 55, 60,
<span class="lineNum">      33 </span>                :   21, 34, 37, 47, 50, 56, 59, 61,
<span class="lineNum">      34 </span>                :   35, 36, 48, 49, 57, 58, 62, 63
<span class="lineNum">      35 </span>                : };
<span class="lineNum">      36 </span>                : 
<span class="lineNum">      37 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">      38 </span>                : 
<span class="lineNum">      39 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">      40 </span>                :  * jpeg_natural_order[i] is the natural-order position of the i'th element
<span class="lineNum">      41 </span>                :  * of zigzag order.
<span class="lineNum">      42 </span>                :  *
<span class="lineNum">      43 </span>                :  * When reading corrupted data, the Huffman decoders could attempt
<span class="lineNum">      44 </span>                :  * to reference an entry beyond the end of this array (if the decoded
<span class="lineNum">      45 </span>                :  * zero run length reaches past the end of the block).  To prevent
<span class="lineNum">      46 </span>                :  * wild stores without adding an inner-loop test, we put some extra
<span class="lineNum">      47 </span>                :  * &quot;63&quot;s after the real entries.  This will cause the extra coefficient
<span class="lineNum">      48 </span>                :  * to be stored in location 63 of the block, not somewhere random.
<span class="lineNum">      49 </span>                :  * The worst case would be a run-length of 15, which means we need 16
<span class="lineNum">      50 </span>                :  * fake entries.
<span class="lineNum">      51 </span>                :  */</FONT></I>
<span class="lineNum">      52 </span>                : 
<span class="lineNum">      53 </span>                : <B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> jpeg_natural_order[DCTSIZE2+16] = {
<span class="lineNum">      54 </span>                :   0,  1,  8, 16,  9,  2,  3, 10,
<span class="lineNum">      55 </span>                :  17, 24, 32, 25, 18, 11,  4,  5,
<span class="lineNum">      56 </span>                :  12, 19, 26, 33, 40, 48, 41, 34,
<span class="lineNum">      57 </span>                :  27, 20, 13,  6,  7, 14, 21, 28,
<span class="lineNum">      58 </span>                :  35, 42, 49, 56, 57, 50, 43, 36,
<span class="lineNum">      59 </span>                :  29, 22, 15, 23, 30, 37, 44, 51,
<span class="lineNum">      60 </span>                :  58, 59, 52, 45, 38, 31, 39, 46,
<span class="lineNum">      61 </span>                :  53, 60, 61, 54, 47, 55, 62, 63,
<span class="lineNum">      62 </span>                :  63, 63, 63, 63, 63, 63, 63, 63, <I><FONT COLOR="#B22222">/* extra entries for safety in decoder */</FONT></I>
<span class="lineNum">      63 </span>                :  63, 63, 63, 63, 63, 63, 63, 63
<span class="lineNum">      64 </span>                : };
<span class="lineNum">      65 </span>                : 
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">      68 </span>                :  * Arithmetic utilities
<span class="lineNum">      69 </span>                :  */</FONT></I>
<span class="lineNum">      70 </span>                : 
<span class="lineNum">      71 </span>                : <B><FONT COLOR="#0000FF">GLOBAL</FONT></B>(<B><FONT COLOR="#228B22">long</FONT></B>)
<span class="lineNum">      72 </span><span class="lineCov">           40878: <B><FONT COLOR="#0000FF">jdiv_round_up</FONT></B> (<B><FONT COLOR="#228B22">long</FONT></B> a, <B><FONT COLOR="#228B22">long</FONT></B> b)</span>
<span class="lineNum">      73 </span>                : <I><FONT COLOR="#B22222">/* Compute a/b rounded up to next integer, ie, ceil(a/b) */</FONT></I>
<span class="lineNum">      74 </span>                : <I><FONT COLOR="#B22222">/* Assumes a &gt;= 0, b &gt; 0 */</FONT></I>
<span class="lineNum">      75 </span>                : {
<span class="lineNum">      76 </span><span class="lineCov">           40878:   <B><FONT COLOR="#A020F0">return</FONT></B> (a + b - 1L) / b;</span>
<span class="lineNum">      77 </span>                : }
<span class="lineNum">      78 </span>                : 
<span class="lineNum">      79 </span>                : 
<span class="lineNum">      80 </span>                : <B><FONT COLOR="#0000FF">GLOBAL</FONT></B>(<B><FONT COLOR="#228B22">long</FONT></B>)
<span class="lineNum">      81 </span><span class="lineCov">            2554: <B><FONT COLOR="#0000FF">jround_up</FONT></B> (<B><FONT COLOR="#228B22">long</FONT></B> a, <B><FONT COLOR="#228B22">long</FONT></B> b)</span>
<span class="lineNum">      82 </span>                : <I><FONT COLOR="#B22222">/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */</FONT></I>
<span class="lineNum">      83 </span>                : <I><FONT COLOR="#B22222">/* Assumes a &gt;= 0, b &gt; 0 */</FONT></I>
<span class="lineNum">      84 </span>                : {
<span class="lineNum">      85 </span><span class="lineCov">            2554:   a += b - 1L;</span>
<span class="lineNum">      86 </span><span class="lineCov">            2554:   <B><FONT COLOR="#A020F0">return</FONT></B> a - (a % b);</span>
<span class="lineNum">      87 </span>                : }
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span>                : 
<span class="lineNum">      90 </span>                : <I><FONT COLOR="#B22222">/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays
<span class="lineNum">      91 </span>                :  * and coefficient-block arrays.  This won't work on 80x86 because the arrays
<span class="lineNum">      92 </span>                :  * are FAR and we're assuming a small-pointer memory model.  However, some
<span class="lineNum">      93 </span>                :  * DOS compilers provide far-pointer versions of memcpy() and memset() even
<span class="lineNum">      94 </span>                :  * in the small-model libraries.  These will be used if USE_FMEM is defined.
<span class="lineNum">      95 </span>                :  * Otherwise, the routines below do it the hard way.  (The performance cost
<span class="lineNum">      96 </span>                :  * is not all that great, because these routines aren't very heavily used.)
<span class="lineNum">      97 </span>                :  */</FONT></I>
<span class="lineNum">      98 </span>                : 
<span class="lineNum">      99 </span>                : #<B><FONT COLOR="#5F9EA0">ifndef</FONT></B> <FONT COLOR="#B8860B">NEED_FAR_POINTERS</FONT>	<I><FONT COLOR="#B22222">/* normal case, same as regular macros */</FONT></I>
<span class="lineNum">     100 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">FMEMCOPY</FONT></B>(dest,src,size)	MEMCOPY(dest,src,size)
<span class="lineNum">     101 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">FMEMZERO</FONT></B>(target,size)	MEMZERO(target,size)
<span class="lineNum">     102 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B>				<I><FONT COLOR="#B22222">/* 80x86 case, define if we can */</FONT></I>
<span class="lineNum">     103 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">USE_FMEM</FONT>
<span class="lineNum">     104 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">FMEMCOPY</FONT></B>(dest,src,size)	_fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size))
<span class="lineNum">     105 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">FMEMZERO</FONT></B>(target,size)	_fmemset((void FAR *)(target), 0, (size_t)(size))
<span class="lineNum">     106 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">     107 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">     108 </span>                : 
<span class="lineNum">     109 </span>                : 
<span class="lineNum">     110 </span>                : <B><FONT COLOR="#0000FF">GLOBAL</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     111 </span><span class="lineCov">          295132: <B><FONT COLOR="#0000FF">jcopy_sample_rows</FONT></B> (JSAMPARRAY input_array, <B><FONT COLOR="#228B22">int</FONT></B> source_row,</span>
<span class="lineNum">     112 </span>                : 		   JSAMPARRAY output_array, <B><FONT COLOR="#228B22">int</FONT></B> dest_row,
<span class="lineNum">     113 </span>                : 		   <B><FONT COLOR="#228B22">int</FONT></B> num_rows, JDIMENSION num_cols)
<span class="lineNum">     114 </span>                : <I><FONT COLOR="#B22222">/* Copy some rows of samples from one place to another.
<span class="lineNum">     115 </span>                :  * num_rows rows are copied from input_array[source_row++]
<span class="lineNum">     116 </span>                :  * to output_array[dest_row++]; these areas may overlap for duplication.
<span class="lineNum">     117 </span>                :  * The source and destination arrays must be at least as wide as num_cols.
<span class="lineNum">     118 </span>                :  */</FONT></I>
<span class="lineNum">     119 </span>                : {
<span class="lineNum">     120 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPROW inptr, outptr;
<span class="lineNum">     121 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">FMEMCOPY</FONT>
<span class="lineNum">     122 </span><span class="lineCov">          295132:   <B><FONT COLOR="#228B22">register</FONT></B> size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE));</span>
<span class="lineNum">     123 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B>
<span class="lineNum">     124 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JDIMENSION count;
<span class="lineNum">     125 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">     126 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> row;
<span class="lineNum">     127 </span>                : 
<span class="lineNum">     128 </span><span class="lineCov">          295132:   input_array += source_row;</span>
<span class="lineNum">     129 </span><span class="lineCov">          295132:   output_array += dest_row;</span>
<span class="lineNum">     130 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">          364509: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">          295132: branch 1 taken</span>
</span><span class="lineNum">     131 </span><span class="lineCov">          659641:   <B><FONT COLOR="#A020F0">for</FONT></B> (row = num_rows; row &gt; 0; row--) {</span>
<span class="lineNum">     132 </span><span class="lineCov">          364509:     inptr = *input_array++;</span>
<span class="lineNum">     133 </span><span class="lineCov">          364509:     outptr = *output_array++;</span>
<span class="lineNum">     134 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">FMEMCOPY</FONT>
<span class="lineNum">     135 </span><span class="lineCov">          364509:     FMEMCOPY(outptr, inptr, count);</span>
<span class="lineNum">     136 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B>
<span class="lineNum">     137 </span>                :     <B><FONT COLOR="#A020F0">for</FONT></B> (count = num_cols; count &gt; 0; count--)
<span class="lineNum">     138 </span>                :       *outptr++ = *inptr++;	<I><FONT COLOR="#B22222">/* needn't bother with GETJSAMPLE() here */</FONT></I>
<span class="lineNum">     139 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">     140 </span>                :   }
<span class="lineNum">     141 </span><span class="lineCov">          295132: }</span>
<span class="lineNum">     142 </span>                : 
<span class="lineNum">     143 </span>                : 
<span class="lineNum">     144 </span>                : <B><FONT COLOR="#0000FF">GLOBAL</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     145 </span><span class="lineNoCov">               0: <B><FONT COLOR="#0000FF">jcopy_block_row</FONT></B> (JBLOCKROW input_row, JBLOCKROW output_row,</span>
<span class="lineNum">     146 </span>                : 		 JDIMENSION num_blocks)
<span class="lineNum">     147 </span>                : <I><FONT COLOR="#B22222">/* Copy a row of coefficient blocks from one place to another. */</FONT></I>
<span class="lineNum">     148 </span>                : {
<span class="lineNum">     149 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">FMEMCOPY</FONT>
<span class="lineNum">     150 </span><span class="lineNoCov">               0:   FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));</span>
<span class="lineNum">     151 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B>
<span class="lineNum">     152 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JCOEFPTR inptr, outptr;
<span class="lineNum">     153 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">long</FONT></B> count;
<span class="lineNum">     154 </span>                : 
<span class="lineNum">     155 </span>                :   inptr = (JCOEFPTR) input_row;
<span class="lineNum">     156 </span>                :   outptr = (JCOEFPTR) output_row;
<span class="lineNum">     157 </span>                :   <B><FONT COLOR="#A020F0">for</FONT></B> (count = (<B><FONT COLOR="#228B22">long</FONT></B>) num_blocks * DCTSIZE2; count &gt; 0; count--) {
<span class="lineNum">     158 </span>                :     *outptr++ = *inptr++;
<span class="lineNum">     159 </span>                :   }
<span class="lineNum">     160 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">     161 </span><span class="lineNoCov">               0: }</span>
<span class="lineNum">     162 </span>                : 
<span class="lineNum">     163 </span>                : 
<span class="lineNum">     164 </span>                : <B><FONT COLOR="#0000FF">GLOBAL</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     165 </span><span class="lineCov">          129844: <B><FONT COLOR="#0000FF">jzero_far</FONT></B> (<B><FONT COLOR="#228B22">void</FONT></B> FAR * target, size_t bytestozero)</span>
<span class="lineNum">     166 </span>                : <I><FONT COLOR="#B22222">/* Zero out a chunk of FAR memory. */</FONT></I>
<span class="lineNum">     167 </span>                : <I><FONT COLOR="#B22222">/* This might be sample-array data, block-array data, or alloc_large data. */</FONT></I>
<span class="lineNum">     168 </span>                : {
<span class="lineNum">     169 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">FMEMZERO</FONT>
<span class="lineNum">     170 </span><span class="lineCov">          129844:   FMEMZERO(target, bytestozero);</span>
<span class="lineNum">     171 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B>
<span class="lineNum">     172 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B> FAR * ptr = (<B><FONT COLOR="#228B22">char</FONT></B> FAR *) target;
<span class="lineNum">     173 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> size_t count;
<span class="lineNum">     174 </span>                : 
<span class="lineNum">     175 </span>                :   <B><FONT COLOR="#A020F0">for</FONT></B> (count = bytestozero; count &gt; 0; count--) {
<span class="lineNum">     176 </span>                :     *ptr++ = 0;
<span class="lineNum">     177 </span>                :   }
<span class="lineNum">     178 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">     179 </span><span class="lineCov">          129844: }</span>
</pre>
<hr>
Generated: 2016-04-07&nbsp;17:52 by <a href="http://minormatter.com/zcov">zcov</a><br>
</body>
</html>
